package jp.ekasi.pms.ui.util;

import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.IWorkbenchWindowActionDelegate;

/**
 * Simple implementation of {@link IWorkbenchWindowActionDelegate}.
 */
public abstract class WorkbenchWindowActionDelegate implements IWorkbenchWindowActionDelegate
{
  private IWorkbenchWindow window;
  private ISelection selection;

  /**
   * @return the {@link IWorkbenchWindow} associated with this instance.
   */
  protected IWorkbenchWindow getWindow()
  {
    return window;
  }

  /**
   * @return the {@link ISelection}.
   */
  protected ISelection getSelection()
  {
    return selection;
  }

  /* (non-Javadoc)
   * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#init(org.eclipse.ui.IWorkbenchWindow)
   */
  public void init(IWorkbenchWindow window)
  {
    this.window = window;
  }

  /* (non-Javadoc)
   * @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
   */
  public void selectionChanged(IAction action, ISelection selection)
  {
    this.selection = selection;
  }
  
  /* (non-Javadoc)
   * @see org.eclipse.ui.IWorkbenchWindowActionDelegate#dispose()
   */
  public void dispose()
  {
    window = null;
    selection = null;
  }
}
